package Pet.Management.controller;

import Pet.Management.domain.vo.RouterVo;
import Pet.Management.domain.vo.MenuVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class MenuController {
    
    private static final Logger logger = LoggerFactory.getLogger(MenuController.class);
    
    /**
     * 获取路由信息
     */
    @GetMapping("/getRouters")
    public Map<String, Object> getRouters() {
        logger.info("获取用户路由信息");
        Map<String, Object> resultMap = new HashMap<>();
        
        // 构建路由列表
        List<RouterVo> routerList = new ArrayList<>();
        
        // 系统管理
        RouterVo system = new RouterVo();
        system.setName("System");
        system.setPath("/system");
        system.setHidden(false);
        system.setRedirect("noRedirect");
        system.setComponent("Layout");
        system.setAlwaysShow(true);
        system.setMeta(new RouterVo.MetaVo("系统管理", "system", false, null));
        
        List<RouterVo> systemChildren = new ArrayList<>();
        
        // 用户管理
        RouterVo user = new RouterVo();
        user.setName("User");
        user.setPath("user");
        user.setHidden(false);
        user.setComponent("system/user/index");
        user.setMeta(new RouterVo.MetaVo("用户管理", "user", false, null));
        systemChildren.add(user);
        
        // 宠物管理
        RouterVo pet = new RouterVo();
        pet.setName("Pet");
        pet.setPath("pet");
        pet.setHidden(false);
        pet.setComponent("pet-care/pet/index");
        pet.setMeta(new RouterVo.MetaVo("宠物管理", "pet", false, null));
        systemChildren.add(pet);
        
        system.setChildren(systemChildren);
        routerList.add(system);
        
        // 返回路由信息
        resultMap.put("code", 200);
        resultMap.put("data", routerList);
        resultMap.put("msg", "操作成功");
        
        return resultMap;
    }
} 